from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from .models import User


@admin.register(User)
class UserAdmin(BaseUserAdmin):
    """用户管理"""
    list_display = ('username', 'nickname', 'email', 'coins', 'wins', 'losses', 'win_rate', 'is_active', 'date_joined')
    list_filter = ('is_active', 'is_staff', 'is_superuser', 'date_joined')
    search_fields = ('username', 'nickname', 'email')
    ordering = ('-date_joined',)
    
    fieldsets = BaseUserAdmin.fieldsets + (
        ('游戏信息', {'fields': ('nickname', 'avatar', 'coins', 'wins', 'losses')}),
    )
    
    add_fieldsets = BaseUserAdmin.add_fieldsets + (
        ('游戏信息', {'fields': ('nickname', 'coins')}),
    )
